package com.jersey;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.FIELD)
public class RedemptionBean {
	private String codeProviderType;
	private String codeDisplayType;
	private String instructions;
	private String redtDateStart;
	private String redtDateEnd;

	private static final SimpleDateFormat REDEMPTION_DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy hh:mm");
	
	/**
	 * @return the codeProviderType
	 */
	public String getCodeProviderType() {
		return codeProviderType;
	}
	/**
	 * @param codeProviderType the codeProviderType to set
	 */
	public void setCodeProviderType(String codeProviderType) {
		this.codeProviderType = codeProviderType;
	}
	/**
	 * @return the codeDisplayType
	 */
	public String getCodeDisplayType() {
		return codeDisplayType;
	}
	/**
	 * @param codeDisplayType the codeDisplayType to set
	 */
	public void setCodeDisplayType(String codeDisplayType) {
		this.codeDisplayType = codeDisplayType;
	}
	/**
	 * @return the instructions
	 */
	public String getInstructions() {
		return instructions;
	}
	/**
	 * @param instructions the instructions to set
	 */
	public void setInstructions(String instructions) {
		this.instructions = instructions;
	}
	/**
	 * @return the redtDateStart
	 */
	public String getRedtDateStart() {
		return redtDateStart;
	}
	/**
	 * @param redtDateStart the redtDateStart to set
	 */
	public void setRedtDateStart(String redtDateStart) {
		this.redtDateStart = redtDateStart;
	}
	
	public Date getRedemptionStartDate() {
		try {
			return getRedtDateStart() != null ? REDEMPTION_DATE_FORMAT.parse(getRedtDateStart()) : null;
		} catch (ParseException e) {
			return null;
		}
	}
	/**
	 * @return the redtDateEnd
	 */
	public String getRedtDateEnd() {
		return redtDateEnd;
	}
	
	public Date getRedemptionEndDate() {
		try {
			return getRedtDateEnd() != null ? REDEMPTION_DATE_FORMAT.parse(getRedtDateEnd()) : null;
		} catch (ParseException e) {
			return null;
		}
	}
	/**
	 * @param redtDateEnd the redtDateEnd to set
	 */
	public void setRedtDateEnd(String redtDateEnd) {
		this.redtDateEnd = redtDateEnd;
	}
	
	public void setRedtDateEnd(Date redemptionEndDate) {
		if(redemptionEndDate != null) {
			setRedtDateEnd(REDEMPTION_DATE_FORMAT.format(redemptionEndDate));
		}
	}

	public void setRedtDateStart(Date redemptionStartDate) {
		if(redemptionStartDate != null) {
			setRedtDateStart(REDEMPTION_DATE_FORMAT.format(redemptionStartDate));
		}
	}

}
